#include "main_header.h"
#define BLOCK_SIZE (4 * 1024 * 1024)      // 4MB接收块
#define MMAP_CHUNK (256 * 1024 * 1024)    // 256MB映射段
int main(int argc, char *argv[]){
    ARGS_CHECK(argc,4);
    Main_thread main_Thread;
    int workNum = atoi(argv[3]);
    init_all(&main_Thread,workNum);
    int sockfd = Tcp_connect(argv[1],argv[2]); 
    makeworker(&main_Thread);
    int epfd = epoll_create(1);
    epoll_add(epfd,sockfd);
    struct epoll_event readyset[1024];
    train_t train;
    bzero(&train,sizeof(train));
    while(1){
        int readyNum = epoll_wait(epfd,readyset,1024,-1);
        for(int i = 0 ; i < readyNum ; i++){
            if(readyset[i].data.fd == sockfd){
                int netfd = accept(sockfd,NULL,NULL);
                printf("netfd ==   %d   connect\n",netfd);
                pthread_mutex_lock(&main_Thread.mutex);
                insert_tail(&main_Thread.queue,netfd);
                pthread_cond_signal(&main_Thread.cond);
                pthread_mutex_unlock(&main_Thread.mutex);
            }
        }
    }
    return 0;
}

